<?php
    include("db/conexion.php");
    include("db/cquery.php");
    
    $query = new CQuery();
    
    $id = $_POST['buscar'];
    
?>

<!DOCTYPE html PUBLIC "-//WC3//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
    <head>
    
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        
        <title>IM InfoMedia</title>
        <link rel="shortcut icon" href="images/favicon.png">
        <link rel="icon" href="images/favicon.png">
        <link rel="stylesheet" href="css/base.css">
        <script type="text/javascript" src="js/jquery-1.7.1.min.js"></script>
        
    </head>
    <body>
    <div id="background" align="center">
      <div id="web" style="">
        <?php include("header.php"); ?>        
                <div id="content">
          <div id="main-menu" style="position: absolute; z-index: 10; left: -31px;">
            <?php $menu=""; include("menu.php"); ?>
            </div>
                <div style="min-height: 100px;">
                    <br /><br />
              <div id="content1" style=" height: auto; width: 500px; left: 1%;">
               
               
                <?php
                if($id==""||$id==" "||$id=="null"){
                    echo "<h1>El campo de búsqueda no puede estar vacío. Por favor intente de nuevo.</h1>";
                }else{ ?>
                
                    <h1>Resultados de su búsqueda "<?php echo $id; ?>"</h1>
                    <?php 
                    $sql= "SELECT * FROM `news` WHERE titulo like '%$id%' OR 'news' like '%$id%' order by id desc";
                    $resEmp = mysql_query($sql, $dbh) or die(mysql_error());
                    $sql=mysql_fetch_array($resEmp);
                    
                    while($news = mysql_fetch_array($resEmp)){ ?>
                        <div style="height: 5px; background-color: black;"></div>
                        <div style="position: relative; min-height: 200px; height: auto;">
                            <div style="position: relative;" align="center">
                                <p><b><a href="noticia.php?id=<?php echo $news['id']; ?>"><?php echo $news['titulo']; ?></a></b></p>
                            </div>
                            <div style="position: absolute; margin-left: 20px;" align="center">
                                <img src="../newsimages/<?php echo $news['image']; ?>" style="position: absolute; width: 200px;"/>
                            </div>
                            <div style="position: relative; margin-left: 50%; margin-right: 20px;">
                                <?php echo strip_tags(substr(utf8_decode($news['news']),0,strrpos(substr(utf8_decode($news['news']),0,200)," ")))."..."; ?>
                            </div>
                        </div>
                <?php }
                }
            ?>
                    </div>
                    <!--
                    <div id="content2" style="position: relative; margin-top: 30px;">
                        <?php //include("secciones.php"); ?>
                    </div>
                    -->
                    
                </div>
            </div>
            <div style="position: absolute; margin-top: -10px; width: 100%">
                       <img src="images/footer.png" width="100%"/>
                   </div>
          
        </div>
    </div>
    </body>
</html>